<?php
/**
 * Created by PhpStorm.
 * User: zhangjijian
 * Date: 2017/6/22
 * Time: 下午5:51
 */

namespace App\Http\Controllers;

use Illuminate\Request;
use Illuminate\Http\Controllers\Controller;

class PostController extends Controller
{
    public function create(){
        return view('post.create');
    }

    public function store(Request $request)
    {
        //
//        $this->validate($request,[
//            'title'=>'required|unique:posts|max:255',
//            'body'=>'required',
//            'publish_at'=>'nullable|date'
//        ]);
//
        $validator = Validator::make($request->all(),[
            'title'=>'required|unique:posts|max:255',
            'body'=>'required',
        ]);

        if($validator->fails()){
            return redirect('post/create')
                ->withErrors($validator)
                ->widthInput();
        }


    }
}